import Home from "../pages/Home"
import PageFirst from "../pages/PageFirst"
import PageSecond from "../pages/PageSecond"

export default {
    '/': Home,
    '/first': PageFirst,
    '/second': PageSecond,
} as Record<string, React.ComponentType>

export class Router {
    static routes_stack: string[] = []
    static updateFn: any | null = null
    static setUpdateFn(fn: any) {
        this.updateFn = fn
    }
    static getCurrentRoute() {
        return this.routes_stack[this.routes_stack.length - 1] || '/'
    }
    static pushRoute(route: string) {
        this.routes_stack.push(route)
        if (this.updateFn) {
            this.updateFn(route)
        }
    }
    static popRoute() {
        const route = this.routes_stack.pop()
        if (this.updateFn) {
            this.updateFn(route || '/')
        }
    }
}